package com.szholly.pro.watergas_server.water.operationsunit;

import java.util.HashMap;

import com.szholly.data.general.Field;
import com.szholly.data.general.GlobalDataType;
import com.szholly.data.general.InterceptorTableBase;
import com.szholly.data.general.metadata.IBaseTable;
import com.szholly.data.general.metadata.table.DefulatDomainTable;
import com.szholly.plug.form.validation.ValidationRegex;
import com.szholly.utils.spring.SpringBeanFactory;
import org.springframework.stereotype.Component;
/**
 * OperationsUnit
 */
@Component("OperationsUnit")
public class OperationsUnitTable extends InterceptorTableBase implements IBaseTable {

	public final static String TABLE_NAME = "OPERATIONS_UNIT";
	
	/**
	 * single ref
	 */
	public static OperationsUnitTable getSingleRef() {
		return (OperationsUnitTable) SpringBeanFactory.getBean("OperationsUnit");
	}

	@Override
	public String getMetadataTableName() {
		return TABLE_NAME;
	}

	@Override
	public String getMetadataTableAliasName() {
		return "OperationsUnit";
	}

	private HashMap<String, Field> fields;

	@Override
	protected HashMap<String, Field> fields() {
		if (fields == null) {
			fields = new HashMap<String, Field>();

			Field itemField = null;
			
			itemField = new Field();
			itemField.setFieldName(OperationsUnitRow.FIELD_CompanyType);
			itemField.setDataType(GlobalDataType.String);
			itemField.setFieldID(5);
			itemField.setFieldAliasName("企业性质");
			itemField.setCodeTablePK(DefulatDomainTable.TABLE_NAME);
			itemField.setCodeDomainName("COMPANY_TYPE");
			itemField.setAllowNull(true);
			itemField.setMaxLen(100);
			fields.put(itemField.getFieldName().toUpperCase().trim(), itemField);
			
			itemField = new Field();
			itemField.setFieldName(OperationsUnitRow.FIELD_LegalPerson);
			itemField.setDataType(GlobalDataType.String);
			itemField.setFieldID(6);
			itemField.setFieldAliasName("法人");
			itemField.setAllowNull(true);
			itemField.setMaxLen(400);
			fields.put(itemField.getFieldName().toUpperCase().trim(), itemField);
			
			itemField = new Field();
			itemField.setFieldName(OperationsUnitRow.FIELD_BuildDate);
			itemField.setDataType(GlobalDataType.DateTime);
			itemField.setFieldID(7);
			itemField.setFieldAliasName("成立时间");
			itemField.setAllowNull(true);
			fields.put(itemField.getFieldName().toUpperCase().trim(), itemField);
			
			itemField = new Field();
			itemField.setFieldName(OperationsUnitRow.FIELD_OperationsUnit);
			itemField.setDataType(GlobalDataType.String);
			itemField.setFieldID(8);
			itemField.setFieldAliasName("运营单位");
			itemField.setAllowNull(true);
			itemField.setMaxLen(100);
			fields.put(itemField.getFieldName().toUpperCase().trim(), itemField);
			
			itemField = new Field();
			itemField.setFieldName(OperationsUnitRow.FIELD_StaffNum);
			itemField.setDataType(GlobalDataType.Int32);
			itemField.setFieldID(9);
			itemField.setFieldAliasName("员工人数");
			itemField.setAllowNull(true);
			fields.put(itemField.getFieldName().toUpperCase().trim(), itemField);
			
			itemField = new Field();
			itemField.setFieldName(OperationsUnitRow.FIELD_Guid);
			itemField.setDataType(GlobalDataType.String);
			itemField.setFieldID(10);
			itemField.setFieldAliasName("GUID");
			itemField.setAllowNull(true);
			itemField.setIsKey(true);
			itemField.setMaxLen(100);
			fields.put(itemField.getFieldName().toUpperCase().trim(), itemField);
			
			itemField = new Field();
			itemField.setFieldName(OperationsUnitRow.FIELD_Email);
			itemField.setDataType(GlobalDataType.String);
			itemField.setFieldID(11);
			itemField.setFieldAliasName("邮箱");
			itemField.setAllowNull(true);
			itemField.setMaxLen(100);
			itemField.setRegEx(ValidationRegex.EMAIL);
			fields.put(itemField.getFieldName().toUpperCase().trim(), itemField);
			
			itemField = new Field();
			itemField.setFieldName(OperationsUnitRow.FIELD_RegisterMoney);
			itemField.setDataType(GlobalDataType.Int32);
			itemField.setFieldID(12);
			itemField.setFieldAliasName("注册资金");
			itemField.setAllowNull(true);
			fields.put(itemField.getFieldName().toUpperCase().trim(), itemField);
			
			itemField = new Field();
			itemField.setFieldName(OperationsUnitRow.FIELD_Name);
			itemField.setDataType(GlobalDataType.String);
			itemField.setFieldID(13);
			itemField.setFieldAliasName("单位名称");
			itemField.setAllowNull(false);
			itemField.setMaxLen(400);
			fields.put(itemField.getFieldName().toUpperCase().trim(), itemField);
			
			itemField = new Field();
			itemField.setFieldName(OperationsUnitRow.FIELD_MobilePhone);
			itemField.setDataType(GlobalDataType.String);
			itemField.setFieldID(14);
			itemField.setFieldAliasName("联系电话");
			itemField.setRegEx("^((0\\d{2,3}-\\d{7,8})|(1[3584]\\d{9}))$");
			itemField.setAllowNull(true);
			itemField.setMaxLen(40);
			itemField.setRegEx(ValidationRegex.MOBILE_PHONE);
			fields.put(itemField.getFieldName().toUpperCase().trim(), itemField);
			
			itemField = new Field();
			itemField.setFieldName(OperationsUnitRow.FIELD_Note);
			itemField.setDataType(GlobalDataType.String);
			itemField.setFieldID(15);
			itemField.setFieldAliasName("公司简介");
			itemField.setAllowNull(true);
			itemField.setMaxLen(1000);
			fields.put(itemField.getFieldName().toUpperCase().trim(), itemField);
			
			itemField = new Field();
			itemField.setFieldName(OperationsUnitRow.FIELD_Address);
			itemField.setDataType(GlobalDataType.String);
			itemField.setFieldID(16);
			itemField.setFieldAliasName("单位地址");
			itemField.setAllowNull(true);
			itemField.setMaxLen(400);
			fields.put(itemField.getFieldName().toUpperCase().trim(), itemField);
			
			itemField = new Field();
			itemField.setFieldName(OperationsUnitRow.FIELD_Photo);
			itemField.setDataType(GlobalDataType.String);
			itemField.setFieldID(17);
			itemField.setFieldAliasName("照片");
			itemField.setAllowNull(true);
			itemField.setMaxLen(600);
			fields.put(itemField.getFieldName().toUpperCase().trim(), itemField);
			
			itemField = new Field();
			itemField.setFieldName(OperationsUnitRow.FIELD_Contacts);
			itemField.setDataType(GlobalDataType.String);
			itemField.setFieldID(18);
			itemField.setFieldAliasName("联系人");
			itemField.setAllowNull(true);
			itemField.setMaxLen(100);
			fields.put(itemField.getFieldName().toUpperCase().trim(), itemField);
		}
		return fields;
	}

	@Override
	public String getTableGroup() {
		return "OperationsUnit";
	}
}